import { Provide,} from '@midwayjs/core';
import { Repository } from 'typeorm';
import { InjectEntityModel } from '@midwayjs/typeorm';
import { user } from '../entity/user.entity';
import { uuidv7 } from 'uuidv7';
import { UserDto } from '../dto/userDto';
@Provide()
export class authDao {

    @InjectEntityModel(user)
    userModel: Repository<user>;
    
    //register
    async register(account:UserDto['account'], password:UserDto['password'], name:UserDto['name'], email:UserDto['email']): Promise<user> {
        const userData = new user();
        userData.account = account;
        userData.password = password;
        userData.name = name;
        userData.email = email;
        userData.valid_flag = 1;//默认有效
        userData.user_id = uuidv7();
        userData.create_time = new Date();
    return await this.userModel.save(userData);
    }
}
